import request from '@/utils/request/index.js'
export default {
	//查询需求列表点选关键字
	getDemandDetail(demandId){
		return request.request({
			url:"/h5/nocdemand/info/" + demandId,
			method:'post',
		})
	},

	//查询当前用户是否参与当前需求
	queryIfJoin(demandInfo){
		if(demandInfo.ifDistribution == 0){
			request.request({
				url:"/h5/demandContact/querycontact",
				method:'post',
				data:{demandId : demandInfo.id},
			}).then(response =>{
				if(response.data.size > 0){
					return true;
				}else{
					return false;
				}
			})
		}else if(demandInfo.ifDistribution == 1){
			request.request({
				url:"/h5/nocDemandDistribution/querydistribution",
				method:'post',
				data:{demandId : demandInfo.id},
			}).then(response =>{
				if(response.data.size > 0){
					return true;
				}else{
					return false;
				}
			})
		}
	},
	/**获取公开需求允许匹配几个
	 * @param {Object} demandId
	 */
	getSetLimit(demandId){
		return request.request({
			url:"/h5/nocdemand/ifReachLimit/" + demandId,
			method:'post'
		})
	},
	/**
	 * 根据需求获取当前用户产品是否满足标签组
	 * @param demandId
	 * @returns {Promise<boolean>}
	 */
	getIfConformTags(demandId){
		return request.request({
			url:"/h5/nocdemand/getIfConformTags/" + demandId,
			method:"get",
		})
	},
	/**判断是否有指定数量产品
	 * @param {Object} userId
	 */
	verifyProductCount(userId){
		return request.request({
			url:"/h5/nocproduct/productCount/" + userId,
			method:"get"
		})
	},
	/**保存会员权益选配需求
	 * @param {Object} demandId
	 */
	saveDistributionUseMember(demandId){
		return request.request({
			url:"/h5/nocDemandDistribution/saveDemandDistribution",
			method:"post",
			data:{
				demandId:demandId,
				ifUseMember : 1
			}
		})
	},
	/**保存选配需求
	 * @param {Object} demandId
	 */
	saveDemandDistribution(demandId){
		return request.request({
			url:"/h5/nocDemandDistribution/saveDemandDistribution",
			method:"post",
			data:{
				demandId:demandId,
				ifUseMember: 0
			}
		})
	},
	/**保存参与公开记录
	 * @param {Object} demandId
	 */
	saveDemandContact(demandId){
		return request.request({
			url:"/h5/nocdemand/saveDemandcontact",
			method:"post",
			data:{
				demandId:demandId
			}
		})
	},
	getVender(userId){
		return request.request({
			url:"/h5/nocuser/info/"+ userId,
			method:"get",
		})
	},
	/**判断是否显示联系方式
	 * 只配给指派的供应商才能看到
	 * @param {Object} demandId
	 */
	queryContactFlag(demandId){
		return request.request({
			url:"/h5/nocDemandDistribution/" + demandId,
			method:"get"
		})
	},
	/**查询成交供应商
	 * @param {Object} demandId
	 */
	getDealCompany(demandId){
		return request.request({
			url:"/h5/nocdemand/getDealCompany",
			method:"post",
			data:{
				demandId:demandId
			}
		})
	},
	/**查询当前用户是否参与该公开需求
	 * @param {Object} demandId
	 */
	queryContact(demandId){
		return request.request({
			url:"/h5/demandContact/querycontact",
			method:"post",
			data:{
				demandId:demandId
			}
		})
	},
	/**查询当前用户是否参与该选配需求
	 * @param {Object} demandId
	 */
	queryDistribution(demandId){
		return request.request({
			url:"/h5/nocDemandDistribution/querydistribution",
			method:"post",
			data:{
				demandId:demandId
			}
		})
	},
	/**查询参与的供应商
	 * @param {Object} ifDistribution
	 * @param {Object} demandId
	 */
	queryCompany(ifDistribution,demandId){
		if(ifDistribution == 0){
			return request.request({
				url:"/h5/noccloudhome/contact",
				method:"post",
				data:{
					demandId:demandId
				}
			})
		}else if(ifDistribution == 1){
			return request.request({
				url:"/h5/noccloudhome/distribution",
				method:"post",
				data:{
					demandId:demandId
				}
			})
		}
	},

}
